package me.ingxin.android.tools.app

import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import me.ingxin.android.badge.Badge
import me.ingxin.android.badge.DotBadge
import me.ingxin.android.badge.NumberBadge
import me.ingxin.android.dialog.LoadingDialog
import me.ingxin.android.tools.app.databinding.ActivityMainBinding
import me.ingxin.android.tools.app.drawer.DrawerActivity
import me.ingxin.android.tools.app.sysbar.SysBarActivity
import me.ingxin.android.tools.dp2px
import me.ingxin.android.tools.singleClick
import me.ingxin.android.tools.startAct

class MainActivity : AppCompatActivity() {

    private val binding by lazy { ActivityMainBinding.inflate(layoutInflater) }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(binding.root)

        window.statusBarColor = Color.WHITE
        val controller = WindowCompat.getInsetsController(window, window.decorView)
        controller.isAppearanceLightStatusBars = true
        controller.isAppearanceLightNavigationBars = true

        binding.btn1.singleClick {
            startActivity(Intent(this, SysBarActivity::class.java))
        }

        binding.btn2.singleClick {
            startActivity(Intent(this, DrawerActivity::class.java))
        }

        binding.btn3.singleClick {
            LoadingDialog(this).setTipWord("加载中...").setDimAmount(0.5f).show()
        }

        binding.btn4.singleClick {
            startAct<SafeKeyboardActivity>()
        }

        val badge = NumberBadge.Builder()
            .setTextSize(dp2px(12f))
            .setRoundPaddingHorizontal(dp2px(6f))
            .setRoundPaddingVertical(dp2px(4f))
            .setCirclePadding(dp2px(8f))
            .setMaxNumber(99)
            .build(binding.btn2)
        badge.setNumb(12)

        val dotBadge = DotBadge.Builder()
            .setRadius(dp2px(6f))
            .setGravity(Badge.Gravity.TopStart)
            .setBackgroundColor(Color.RED)
            .build(binding.btn3)

        dotBadge.setOffset(0, 12)


    }


}